package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/*
    增强型
 */
public class NewForDemo {
    public static void main(String[] ages){
        String[] array = {"one","two","three","for","five"};
        for(int i=0;i<array.length;i++){
            System.out.println(array[i]);
        }
        for(String str :array){//str表示的就是数组中的每个元素
            System.out.println(str);

        }
        System.out.println("-------------");

        Collection<String> c = new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator<String> it = c.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
        for(String str : c){//str表示的是集合中的每个元素
            System.out.println(str);
        }

    }
}
